"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
const fs = __importStar(require("fs"));
const path_1 = __importDefault(require("path"));
const vue_1 = require("vue");
const lib_css_1 = __importDefault(require("../../../../../../../@libs/nodejs-lib-main/lib_css"));
const component = {
    name: 'reward_show',
    props: {
        allReward: Object || String,
        lf: Object || String,
    },
    template: fs.readFileSync(`${__dirname}/reward_show.html`, "utf-8"),
    components: {},
    setup() {
    },
    methods: {
        handleEdit(index, row) {
            this.$data.activeIndex = index;
        },
        handleDelete(index, row) {
            this.$props.allReward.splice(index, 1);
            this.handleSave();
        },
        // 保存行
        handleSave() {
            this.$data.activeIndex = -1;
            console.log("保存奖励", this.$data.filterTableData);
            this.$emit('saveRewardInfo', this.$data.filterTableData);
        },
        onAddItem() {
            const newReward = { reward_name: "变量名称", reward_id: "变量id", reward_desc: "变量描述", reward_value: 0 };
            this.$data.filterTableData.push(newReward);
            this.$emit('saveRewardInfo', this.$data.filterTableData);
            console.log("添加", this.$data.filterTableData);
        }
    },
    data() {
        return {
            search: (0, vue_1.ref)(''),
            activeIndex: (0, vue_1.ref)(-1),
            filterTableData: (0, vue_1.computed)(() => this.$props.allReward.filter((data) => !this.$data.search ||
                data.name.toLowerCase().includes(this.$data.search.toLowerCase())))
        };
    },
    watch: {},
    created() { },
    mounted() {
        lib_css_1.default.load([
            {
                parent: this.$el,
                url_s: path_1.default.join(`${__dirname}/reward_show.css`),
            },
        ]);
    },
};
module.exports = component;
